<?php
	require_once('../includes/config.php');
	$action = "add";
	$readonly = "";
	$proname = "";
	$procat  = "";
	$proid = "";
	$prodetail = "";
	$prospecial = "";
	if($_GET['act'] == "edit")
	{
		$cmnid = $_GET['id'];
		$readonly = "readonly";
		$str_query = "SELECT * FROM tbl_comment WHERE id = '$cmnid'";
		$resul = mysql_query("$str_query") or die ("can not load data for update ");
		$data = mysql_fetch_assoc($resul);
		$cmn_pro = $data['id_product'];
		$cmn_content = $data['comment_content'];
		$action = "edit";
	}
?>
<script type="text/javascript">
$(document).ready(function() {
	$("form#catForm").submit(function(){
		var id = $('#cmnid').attr('value');
		var content = encodeURIComponent($('#cmn_content').attr('value'));
		var act = $("#act").attr('value');
		var datastring = 'act=' + act +
						 '&id=' + id +
						 '&content=' + content ;
		 $.ajax({ 
			 url: "comment_process.php",
			 type: "POST",
			 data: datastring,
			 dataType: 'json',
			 success: function(data){
				 if(data==1)
				 {
					$("#rounded-corner").load("comment_list.php");
					disablePopup();
					$("form").each( function() { this.reset; });
				 }
				 else
				 {
					 alert('Some error occur!');
				 }
			 }
		 });
		 return false;
	});
});
</script>
 
		<a id="popupCommentClose">x</a>
		<h1>Edit Comment</h1>
        <form id="catForm" method="post">
        	<input type="hidden" name="cmnid" id="cmnid" value="<?php echo $cmnid; ?>" />
     		<p>
        		<label>Product Name:</label>
          		<input type="text" name="cmn_pro" id="cmn_pro" readonly="readonly" value="<?php echo _GetProductName($cmn_pro); ?>" />
     		</p>
     		<p>
          		<label>Content:</label>
          		<textarea id="cmn_content" name="cmn_content" style="height:150px; width:350px;"><?php echo $cmn_content; ?> </textarea>
        	</p>
       		<button id="act" type="submit" name="act" value="<?php echo $action; ?>">Save</button>
        </form>
		
	
